<?php
  include("../Includes/FusionCharts_Gen.php");
  include("../Includes/DBConn.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
	<HEAD>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>UPLB DV</title>
		
		<script language="Javascript" src="../js/FusionCharts.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.min.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
		<script type="text/javascript" src="../fancybox/jquery.fancybox-1.3.4.pack.js"></script>
		

		<link rel="stylesheet" href="../fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />

	</HEAD>

	<BODY>
	<CENTER>
			<?php
				$degree = $_GET['degree'];
				if($degree=="default"){
					$degree = "CMSC";
					$AY = 2007;
					
				}
				else{
					$degree = $_POST['degree'];
					$AY = $_POST['AY'];
				}
				
				$yAxis = "passingRate";
				$endAY = $AY + 1;
				
				$FC = new FusionCharts("Bar2D","850","700");
				$FC->setSwfPath("../FusionCharts/");
				$strParam="caption=$degree Courses Passing Rates;subcaption=AY $AY-$endAY;xAxisName=Course Number;yAxisName=Passing Rates; yAxismaxvalue=100;formatNumberScale=0;decimalPrecision=0;numberSuffix= %";
				$FC->setChartParams($strParam);
				$link = connectToDB();
				$strQuery = "select "."$yAxis".", academicYear, courseCode from course where academicYear='$AY' and SUBSTRING(courseCode,1,4)='$degree' order by passingRate";
				
				if($degree!=""){
					$result = mysql_query($strQuery) or die(mysql_error());
				}
				
				if ($result) 
				{
					$FC->addDataFromDatabase($result, $yAxis, 'courseCode');
				}

				mysql_close($link);
				$FC->renderChart();
			?>
	</CENTER>
	</BODY>
</HTML>